package huawei.js2025;

import java.util.Scanner;

/**
 * 箱子之字形摆放
 */
public class Question46 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        sc.close();

        String[] strings = line.split(" ");
        String input = strings[0];

        char[] chars = input.toCharArray();
        int i = 0;

        int N = Integer.parseInt(strings[1]);

        char[][] matrix = new char[N][N];

        for (int col = 0; col < N; col++) {
            if (col % 2 == 0) {
                for (int row = 0; row < N; row++) {
                    char c = chars[i ++];
                    matrix[row][col] = c;
                    if (i == input.length()) {
                        break;
                    }
                }
            } else {
                for (int row = N - 1; row >= 0; row--) {
                    char c = chars[i ++];
                    matrix[row][col] = c;
                    if (i == input.length()) {
                        break;
                    }
                }
            }
            if (i == input.length()) {
                break;
            }
        }

        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (matrix[j][k] != '\u0000') {
                    System.out.print(matrix[j][k]);
                }
            }
            System.out.println();
        }
    }
}
